//导航   下拉菜单
//获取 a标签
var li = document.querySelectorAll(".list");
//console.log(li);
//获取 下拉菜单的内容
var list = document.querySelectorAll(".list div");
//console.log(list);

for(var i = 0; i < li.length; i++) {
	//移入事件
	li[i].addEventListener("mouseover", function() {
		this.children[1].style.display = 'block';
		this.firstElementChild.firstElementChild.style.transform='rotate(180deg)';
		this.firstElementChild.firstElementChild.style.borderTopColor='#FF6633';
	})
	for(var j = 0; j < li.length; j++) {
		//移出事件
		li[j].addEventListener("mouseleave", function() {
			this.children[1].style.display = "none";
			this.firstElementChild.firstElementChild.style.transform='rotate(360deg)';
			this.firstElementChild.firstElementChild.style.borderTopColor='';
		})
	}
}
	
//其他城市
var area = document.querySelector(".area>a");
var group = document.querySelector(".group");
var sp = document.querySelector(".area>span");
//console.log(area);
//点击事件
area.addEventListener("click",function(){
	group.style.display='block';
	sp.style.backgroundImage='url(img/area1.png)';
})
group.addEventListener("mouseleave",function(){
	this.style.display = 'none';
	sp.style.backgroundImage='url(img/area.png)';
})
	
//家居优选  
//当鼠标滑过添加边框
var a = document.querySelectorAll(".improvement-top .row .col-md-3 div");
for(var b=0;b<a.length;b++){
	a[b].onmouseover = function(){
		this.style.border = "2px solid #FF8400";
	}
	a[b].onmouseout = function(){
		this.style.border = "";
	}
}

//返回顶部
//获取#top
var t = document.querySelector("#top");
window.onscroll = function(){
	if(document.documentElement.scrollTop > 500 || document.body.scrollTop > 500){
		t.style.display = 'block';
	}else{
		t.style.display = 'none';
	}
}
t.addEventListener('click', function() {
	//平滑的滚动
	//	window.scrollTo(0,0);

	//	 老版本的浏览器不支持
	window.scrollTo({
		top: 0,
		behavior: 'smooth'
	})

})